<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt' %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Info</title>
        <script type="text/javascript">
        function echeck(str) {

            var at = "@"
            var dot = "."
            var lat = str.indexOf(at)
            var lstr = str.length
            var ldot = str.indexOf(dot)
            if (str.indexOf(at) == -1) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.indexOf(at, (lat + 1)) != -1) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.indexOf(dot, (lat + 2)) == -1) {
                alert("Invalid E-mail ID")
                return false
            }

            if (str.indexOf(" ") != -1) {
                alert("Invalid E-mail ID")
                return false
            }

            return true
        }

        function ValidateForm() {
            var emailID = document.f.username

            if ((emailID.value == null) || (emailID.value == "")) {
                alert("Please Enter your Email ID")
                emailID.focus()
                return false
            }
            if (echeck(emailID.value) == false) {
                emailID.value = ""
                emailID.focus()
                return false
            }

            return true

        }
        </script>
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/1.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/2.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/3.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/4.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/5.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/6.css" />
<link type="text/css" rel="stylesheet" href="/bob-web/CSS/7.css" />
<link rel="stylesheet" type="text/css" href="/bob-web/CSS/3c-lcrc-static-pp-layout.css" />
<link rel="stylesheet" type="text/css" href="/bob-web/CSS/3c-lcrc-static-pp-presentation.css" />
<link rel="stylesheet" type="text/css" href="/bob-web/CSS/2FEu-VTjHxG.css" />
</head>
<body class="profile">
<!-- left column -->
<div id="lh-col"><br />
  <%@ include file="/WEB-INF/jsp/leftScreen.jsp" %>
</div>
<!-- end of left column -->
<!-- center column -->

    <!-- Tabs -->
     <%@ include file="/WEB-INF/jsp/tabs.jsp" %>
     <!-- End of tabs -->



  <div id="reg_box">
    <div id="reg_form_box" class= "large_box" align="left">
        <br />
        <c:choose>
            <c:when test="${model.mode==('list')}">
        <h2>Publication List</h2>
        <br />
                <c:if test="${model.himself}">
                <a href="publications.htm?editId=-1">New publication</a>
                <br /><br />
                </c:if>
<c:choose>
<c:when test="${fn:length(model.publications)==0}"><br />There are no publications</c:when>
<c:otherwise>
    <table border="1" cellpadding="5" cellspacing="0">
    <c:forEach items="${model.publications}" var="result">
        <tr>
            <td width="650">${result.authors}: ${result.title}<c:if test="${fn:length(result.otherInformation)>0}">, ${result.otherInformation}</c:if><c:if test="${fn:length(result.location)>0}">, ${result.location}</c:if><c:if test="${fn:length(result.date)>0}">, ${result.date}</c:if></td>
            <c:if test="${model.himself}">
            <td><a href="publications.htm?editId=${result.publicationId}">Edit</a></td>
            <td><a href="publications.htm?deleteId=${result.publicationId}" onclick="return confirm('Are you sure you want to delete this publication?')">Delete</a></td>
            </c:if>
        </tr>
    </c:forEach>
    </table>
</c:otherwise>
</c:choose>
            </c:when>
            <c:otherwise>
                <c:choose>
                    <c:when test="${model.mode==('edit')}">
                        <h2>Edit Publication</h2>
                    </c:when>
                    <c:otherwise>
                        <h2>New Publication</h2>
                    </c:otherwise>
                </c:choose>

         <br />
         <script type="text/javascript" language="javascript">
             function checkForm()
             {
                 var message="";

                 if(document.getElementById("authors").value.replace(" ", "")=="")
                    message+="Please enter author(s)\n";

                 if(document.getElementById("title").value.replace(" ", "")=="")
                    message+="Please enter title\n";

                 if(message!="")
                 {
                     alert(message);
                     return false;
                 }
                 else
                    return true;
             }
         </script>
         <form action="/bob-web/service/publications.htm" onsubmit="return checkForm()" method="POST">
         <table border="0" cellpadding="5" cellspacing="0">
             <tr>
                 <td colspan="2">
                     <b>
                         * denotes mandatory fields
                     </b>
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <b>
                         Author(s)*
                     </b>
                 </td>
                 <td align="left" width="350">
                     <input type="text" maxlength="200" name="authors" id="authors" class='inputtext' value="${model.publication.authors}" />
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <b>
                         Title*
                     </b>
                 </td>
                 <td align="left" width="350">
                     <input type="text" maxlength="100" name="title" id="title" class='inputtext' value="${model.publication.title}" />
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <b>
                         Location
                     </b>
                 </td>
                 <td align="left" width="350">
                     <input type="text" maxlength="100" name="location" class='inputtext' value="${model.publication.location}" />
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <b>
                         Date
                     </b>
                 </td>
                 <td align="left" width="350">
                     <input type="text" maxlength="100" name="date" class='inputtext' value="${model.publication.date}" />
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <b>
                         Other information
                     </b>
                 </td>
                 <td align="left" width="350">
                     <input type="text" maxlength="250" name="otherInformation" class='inputtext' value="${model.publication.otherInformation}" />
                 </td>
             </tr>
             <tr>
                 <td align="right" width="150">
                     <input type="hidden" name="publicationId" value="${model.publication.publicationId}" />
                 </td>
                 <td align="left" width="350">
                     <label class="UIComposer_SubmitButton uiButton uiButtonConfirm uiButtonLarge">
                         <input type="submit" name="save" value="Save" />
                     </label>
                     <label class="UIComposer_SubmitButton uiButton uiButtonConfirm uiButtonLarge">
                         <input type="button" name="back" value="Back" onclick="history.back();" />
                     </label>
                 </td>
             </tr>
         </table>
         </form>
            </c:otherwise>
        </c:choose>








    </div>
  </div>
</div>
<!-- end of center column -->
<!-- right column -->
<div id="rh-col"> <a href="/bob-web/service/homePage.htm"><img border="0" src="/bob-web/Images/logo.png" alt="BookOfBoun" width="180" height="100" /></a>
  <%@ include file="/WEB-INF/jsp/rightScreen.jsp" %>
</div>
<!-- end of right column -->
</body>
</html>
